package com.tchhy.provider.data.healthy.response

import android.os.Parcel
import android.os.Parcelable
import java.util.ArrayList

/**
 * @author: admin
 * @date: 2019/11/1
 * @des:
 *
 **/
data class MedicineClassificationInfo(
    var isSelect: Boolean = false,
    var selectNum: Int = 0,
    var id: String? = null,
    var commodityId: String? = null,
    var medicineChestId: String? = "",//药箱编号
    var medicineId: String? = "",//药物id
    var salesName: String? = "",//药品名称
    var medicineName: String? = "",
    var dosageFormat: String? = "",//含量规格
    var medicineType: Int? = null,//todo old :1 药厂药 2 自储药 4商城药
    var type: Int? = null,
    var image: ImageItem? = null,//图片
    var indication: String? = "",//适应症
    var partnerPrice: Long? = null,//价格
    var mallCrossedPrice: Long? = null,
    var mallPrice: Long? = null,
    var effective: String? = "",//有效期
    var inventory: Int? = null,//库存
    var typeCodeName: String? = "",//药品分类名字
    var typeCode: String? = null,//药品分类编号
    var coding: String? = "",//药箱编号
    var units: String? = "",//单位
    var usageTimes: String? = null,//每次/用量
    var usageDays: String? = null, //每天/次,
    var timeList: ArrayList<MoreTimeData>? = null
) : Parcelable {
    constructor(source: Parcel) : this(
        1 == source.readInt(),
        source.readInt(),
        source.readString(),
        source.readString(),
        source.readString(),
        source.readString(),
        source.readString(),
        source.readString(),
        source.readString(),
        source.readValue(Int::class.java.classLoader) as Int?,
        source.readValue(Int::class.java.classLoader) as Int?,
        source.readParcelable<ImageItem>(ImageItem::class.java.classLoader),
        source.readString(),
        source.readValue(Long::class.java.classLoader) as Long?,
        source.readValue(Long::class.java.classLoader) as Long?,
        source.readValue(Long::class.java.classLoader) as Long?,
        source.readString(),
        source.readValue(Int::class.java.classLoader) as Int?,
        source.readString(),
        source.readString(),
        source.readString(),
        source.readString(),
        source.readString(),
        source.readString(),
        source.createTypedArrayList(MoreTimeData.CREATOR)
    )

    override fun describeContents() = 0

    override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
        writeInt((if (isSelect) 1 else 0))
        writeInt(selectNum)
        writeString(id)
        writeString(commodityId)
        writeString(medicineChestId)
        writeString(medicineId)
        writeString(salesName)
        writeString(medicineName)
        writeString(dosageFormat)
        writeValue(medicineType)
        writeValue(type)
        writeParcelable(image, 0)
        writeString(indication)
        writeValue(partnerPrice)
        writeValue(mallCrossedPrice)
        writeValue(mallPrice)
        writeString(effective)
        writeValue(inventory)
        writeString(typeCodeName)
        writeString(typeCode)
        writeString(coding)
        writeString(units)
        writeString(usageTimes)
        writeString(usageDays)
        writeTypedList(timeList)
    }

    companion object {
        @JvmField
        val CREATOR: Parcelable.Creator<MedicineClassificationInfo> =
            object : Parcelable.Creator<MedicineClassificationInfo> {
                override fun createFromParcel(source: Parcel): MedicineClassificationInfo =
                    MedicineClassificationInfo(source)

                override fun newArray(size: Int): Array<MedicineClassificationInfo?> =
                    arrayOfNulls(size)
            }
    }
}